app.controller('NetbarDeInfoCtrl', ['$scope','$state', '$stateParams','$http','DiagramService','$anchorScroll','$location',NetbarDeInfoCtrl]);

function NetbarDeInfoCtrl($scope,$state, $stateParams,$http,DiagramService,$anchorScroll,$location){
	$anchorScroll.yOffset = 0;
	$location.hash('');
	$anchorScroll();

	var origin_url = 'http://10.0.13.195:3001/api';
	console.log(111)

	$scope.getHotelData = function(id){
		$http({
			url: origin_url + '/hotelguests?filter={"where": {"zjhm": "'+id+'"}}',
			method:'GET'
			}).success(function(data,header,config,status){
			//响应成功
				$scope.hotelData = data;
				$scope.dfGroup['旅馆']={
					'ms':'频繁入住旅馆，近10天有5天旅馆夜晚住宿记录。',
					'df':40
				}
			
			}).error(function(data,header,config,status){
			//处理响应失败
		});
	}

	$scope.goRelatedPer =function(data){
/*	  localStorage.userId = data;*/
	  var url = $state.href(data,{id:$scope.id});
	  window.open(url,'_blank');
	}


	$scope.getNetbarData = function(id){
		$http({
			url:origin_url + '/netpeople?filter={"order": "swkssj desc","where": {"and": [{"zjhm": "'+id+'"}, {"xwsj": {"neq": ""}}]}}',
			method:'GET'
			}).success(function(data,header,config,status){
			//响应成功
				$scope.barData = data;
				$scope.dfGroup['网吧']={
					'ms':'频繁出入网吧，近10天有4天网吧通宵记录，经常在后半夜登陆电脑。',
					'df':40
				}
			}).error(function(data,header,config,status){
			//处理响应失败
		});
	}

	$scope.getTempLiveData = function(id){
		$http({
			url:origin_url + '/migrants?filter={"where": {"sfzh": "'+id+'"}}',
			method:'GET'
			}).success(function(data,header,config,status){
			//响应成功
				$scope.tempLiveData = data;
				$scope.dfGroup['暂住证']={
					'ms':'无固定住所，经常换居住地点。',
					'df':50
				}


			}).error(function(data,header,config,status){
			//处理响应失败
		});
	}

	$scope.getPreCriminal = function(id){
		$http({
			url:origin_url + '/pedigree_7s?filter={"where": {"sfzh": "'+id+'"}}',
			method:'GET'
			}).success(function(data,header,config,status){
			//响应成功
				$scope.preCriminal = data;
				$scope.dfGroup['七类重点人员']={
					'ms':'无异常信息。',
					'df':10
				}
			}).error(function(data,header,config,status){
			//处理响应失败
		});
	}

	$scope.getImpPer = function(id){
		$http({
			url:origin_url + '/pedigree_dfks?filter={"where": {"sfzh": "'+id+'"}}',
			method:'GET'
			}).success(function(data,header,config,status){
			//响应成功
				$scope.impPers = data;
				$scope.dfGroup['打防控人员']={
					'ms':'无异常信息。',
					'df':0
				}
			}).error(function(data,header,config,status){
			//处理响应失败
		});
	}

	$scope.getCrimePer = function(id){
		$http({
			url:origin_url + '/pedigree_bas?filter={"where": {"sfzh": "'+id+'"}}',
			method:'GET'
			}).success(function(data,header,config,status){
			//响应成功
				$scope.crimePer = data;
				$scope.dfGroup['执法办案嫌疑人']={
					'ms':'无异常信息。',
					'df':10
				}

			}).error(function(data,header,config,status){
			//处理响应失败
		});
	}

	$scope.getPerInfo = function(id){
		$http({
			url:origin_url + '/zdries?filter={"where": {"sfzh": "'+id+'"}}',
			method:'GET'
			}).success(function(data,header,config,status){
			//响应成功
				$scope.perInfo = data[0]
			}).error(function(data,header,config,status){
			//处理响应失败
		});
	}

	$scope.getRelatedPeople = function(id){
		var data = [
			{	
				sfzh:'340421199710173014',
				xm:'罗宋',
				ms:'频繁出入网吧，近10天有4天网吧通宵记录，经常在后半夜登陆电脑。',
				df:90
			},
						{	
				sfzh:220103,
				xm:'张大明',
				ms:'频繁出入网吧，近10天有4天网吧通宵记录，经常在后半夜登陆电脑。',
				df:100
			},
						{	
				sfzh:220104,
				xm:'张大明',
				ms:'频繁出入网吧，近10天有4天网吧通宵记录，经常在后半夜登陆电脑。',
				df:97
			},			{	
				sfzh:220105,
				xm:'张大明',
				ms:'频繁出入网吧，近10天有4天网吧通宵记录，经常在后半夜登陆电脑。',
				df:50
			},
						{	
				sfzh:220106,
				xm:'张大明',
				ms:'频繁出入网吧，近10天有4天网吧通宵记录，经常在后半夜登陆电脑。',
				df:40
			}
		]
		$scope.relatedPeople = data;

	}

	$scope.id = $stateParams.id;
	$scope.tempLiveData = $scope.getTempLiveData($scope.id)
	$scope.preCriminal = $scope.getPreCriminal($scope.id)
	$scope.impPers = $scope.getImpPer($scope.id)
	$scope.perInfo = $scope.getPerInfo($scope.id);
	$scope.getCrimePer($scope.id)
	$scope.hotelData = $scope.getHotelData($scope.id);
	$scope.barData = $scope.getNetbarData($scope.id);
	$scope.getRelatedPeople($scope.id)

	//显示各组的得分信息
	$scope.dfGroup= {};

	$scope.haveInfo=function(val){
/*		if($scope.ctrlOption.indexOf(val)>-1){
			return true;
		}else{
			return false;
		}*/
		return true;
	}

	$scope.checkInfo=function(val){
/*		var index = $scope.ctrlOption.indexOf(val);
		if(index>-1){
			$scope.ctrlOption.splice(index,1)
		}else{
			$scope.ctrlOption.push(val)
		}*/
	}

	$scope.getSuggestion = function(){
		$scope.editState = 'noedit'
		$scope.choiceSuggest = ''
		$scope.suggest_save = $scope.choiceSuggest;
		$scope.suggestion='';
		$scope.suggestion_save = $scope.suggestion;
		if($scope.choiceSuggest==''&&$scope.suggestion==''){
			$scope.editState = 'edit'
		}
	}

	$scope.getSuggestion();

	$scope.openEdit = function(){
		$scope.editState='edit'
	}

	$scope.resetSuggestion = function(){
		$scope.editState = 'onlyread'
		$scope.choiceSuggest = $scope.suggest_save;
		$scope.suggestion = $scope.suggestion_save;
	}

	$scope.submitSuggestion = function(){
		$scope.editState = 'onlyread'
		$scope.suggest_save = $scope.choiceSuggest;
		$scope.suggestion_save = $scope.suggestion;
	}

	$scope.chooseSuggest = function(index){
		if($scope.editState=='edit'){
			$scope.choiceSuggest = index;
		}
	}

	$scope.emptyTextArea = function(){
		$scope.suggestion = '';
	}


}
